define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: '/addon/msg_board',
        edit_url: '/addon/msg_board/edit',
        delete_url: '/addon/msg_board/destroy',
    };

    return {

        index: function () {

            ea.table.render({
                init: init,
                toolbar: ['refresh', 'delete'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', minWidth: 80, title: '序号'},
                    {field: 'first_name', minWidth: 80, title: '姓'},
                    {field: 'last_name', minWidth: 80, title: '名'},
                    {field: 'email', minWidth: 80, title: 'Email'},
                    {field: 'phone', minWidth: 80, title: '手机号码'},
                    {field: 'subject', minWidth: 80, title: '主题'},
                    {field: 'content', minWidth: 80, title: '内容'},
                    {
                        field: 'status', minWidth: 80, title: '状态', templet: function (d) {
                            return d.status == 1 ? '<span style="color: green">已处理</span>' : '<span style="color: red">待处理</span>';
                        }
                    },
                    {field: 'created_at', minWidth: 120, title: '时间'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            'edit',
                            'delete'
                        ]
                    }
                ]],
            });

            ea.listen();
        },
        edit: function () {
            ea.listen();
        }
    };
});
